package com.gzk.oeno.business.pays;

import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.lang.StringUtils;

import com.gzk.utils.CustomException;
import com.gzk.utils.parsing.AbstractParserMapper;

public class PaysImportMapper extends AbstractParserMapper<Pays>{

	private static final int COL_NAME		= 0;
	
	private static final String[] COLUMNS = new String[]{
		"Nom"
	};
	
	public PaysImportMapper() {
		super(COLUMNS);
	}
	
	@Override
	protected Pays convert(int line, Map<Integer, String> fields)
			throws CustomException {
		
		String name = null;
		
		for (Entry<Integer, String> entry : fields.entrySet()){
			String text = entry.getValue();
			
			switch (entry.getKey()){
			case COL_NAME:
				name = text;
				break;
			}
		}
		
		if (StringUtils.isNotEmpty(name)){
			return new Pays(name);
		}
		return null;
	}

}
